package com.yvan.game.merge.service;

import com.yvan.game.merge.dao.UserAccountMapper;
import com.yvan.game.merge.dao.UserInfoMapper;
import com.yvan.game.merge.vo.UserState;
import com.yvan.platform.YvanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(readOnly = true)
public class UserService {

    @Autowired
    private UserAccountMapper userAccountMapper;

    @Autowired
    private UserInfoMapper userInfoMapper;

    public UserState selectState(String userId) {
        UserState r = new UserState();
        r.setUserAccount(userAccountMapper.selectById(userId));
        r.setUserInfo(userInfoMapper.selectById(userId));
        return r;
    }

    public int saveSeat(String userId, int[] seatArray) {
        return userAccountMapper.saveSeat(userId, YvanUtil.toJson(seatArray));
    }
}
